{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import pickle\n",
    "\n",
    "import seaborn as sns\n",
    "\n",
    "sns.set(style = \"darkgrid\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# fill in:\n",
    "epochs = 200\n",
    "filename = ''\n",
    "model = 'resnet'\n",
    "lr = 0.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# edit this with the desired filename\n",
    "file_name = './results/{}_{}_{}_{}.pkl'.\\\n",
    "    format(filename, model, epochs, lr)\n",
    "\n",
    "TL = []\n",
    "TA = []\n",
    "TLC = []\n",
    "TAC = []\n",
    "TLN = []\n",
    "TAN = []\n",
    "TEL = []\n",
    "TEA = []\n",
    "phibef = []\n",
    "phiaft = []\n",
    "\n",
    "f = open(file_name, 'rb')\n",
    "unpickler = pickle.Unpickler(f)\n",
    "for epoch in range(200):\n",
    "    [ep, phi_out_bef, phi_out_aft,\n",
    "         tl, ta, tlc, tac, tln, tan,\n",
    "         tel, tea] = unpickler.load()\n",
    "    TL.append(tl)\n",
    "    TA.append(ta)\n",
    "    TLC.append(tlc)\n",
    "    TAC.append(tac)\n",
    "    TLN.append(tln)\n",
    "    TAN.append(tan)\n",
    "    TEL.append(tel)\n",
    "    TEA.append(tea)\n",
    "    phibef.append(phi_out_bef)    \n",
    "    phiaft.append(phi_out_aft)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig, axss = plt.subplots(1, 1, figsize=[10,6])\n",
    "\n",
    "axs = axss\n",
    "axs.plot(range(epochs), TAN, label='train acc noisy', linewidth=10.0)\n",
    "\n",
    "\n",
    "axs.set_xlabel('Epochs', fontsize=40)\n",
    "axs.set_ylabel('ACC', fontsize=40)\n",
    "axs.tick_params(axis='y', labelsize=27)\n",
    "axs.tick_params(axis='x', labelsize=27)\n",
    "axs.legend(prop={'size': 30}, loc='upper left')\n",
    "axs.set_ylim(bottom=0, top=100)\n",
    "\n",
    "plt.tight_layout()\n",
    "#plt.savefig('.png',bbox_inches='tight')\n",
    "\n",
    "fig, axss = plt.subplots(1, 1, figsize=[9.75,6])\n",
    "\n",
    "axs = axss\n",
    "\n",
    "r = [a-b for a,b in zip(phibef, phiaft)]\n",
    "r2 = [sum(r[1:t])/t for t in range(1,epochs)]\n",
    "axs.plot(range(epochs)[1:], r2[:], linewidth=10.0)\n",
    "\n",
    "\n",
    "axs.set_xlabel('Epochs', fontsize=40)\n",
    "axs.set_ylabel(r'Susceptibility $\\zeta$ ', fontsize=40)\n",
    "axs.tick_params(axis='y', labelsize=27)\n",
    "axs.tick_params(axis='x', labelsize=27)\n",
    "\n",
    "plt.tight_layout()\n",
    "#plt.savefig('.png',bbox_inches='tight')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
